import { Suspense } from "react";
import { Skeleton } from "@/components/ui/skeleton";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import VendorDocumentPage from "./vendor-document-page";
import { Shell } from "@/components/shell";

export const metadata = {
  title: "Document Search and Upload",
  description: "Vendor Document Search and File Upload",
};

// ============================================================================
// 로딩 스켈레톤
// ============================================================================

function VendorDocumentSkeleton() {
  return (
    <Card>
      <CardHeader>
        <div className="flex items-center justify-between">
          <Skeleton className="h-8 w-32" />
          <Skeleton className="h-10 w-40" />
        </div>
      </CardHeader>
      <CardContent className="space-y-4">
        <Skeleton className="h-32 w-full" />
        <Skeleton className="h-96 w-full" />
      </CardContent>
    </Card>
  );
}

export default async function DocumentUploadPage({
  searchParams,
}: {
  searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
}) {
  const params = await searchParams;
  
  return (
    <Shell>
      {/* 헤더 */}
      <div className="flex items-center justify-between">
        <div>
          <h2 className="text-2xl font-bold tracking-tight">
            SWP Document Submission
          </h2>
        </div>
      </div>

      {/* 메인 컨텐츠 */}
      <Suspense fallback={<VendorDocumentSkeleton />}>
        <VendorDocumentPage searchParams={params} />
      </Suspense>
    </Shell>
  );
}